<script type="text/javascript" src="__PUBLIC__/js/jia.js"></script>
<form id="pagerForm" method="post" action="{:U($module_name.'/'.$action_name)}" onsubmit="return divSearch(this, 'priceBox');">
	<input type="hidden" name="pageNum" value="{$pageNum}" />
	<input type="hidden" name="numPerPage" value="{$numPerPage}" />
	<input type="hidden" name="orderField" value="{$orderField}" />
	<input type="hidden" name="orderDirection" value="{$orderDirection}" />
	<input type="hidden" name="keywords" value="{$keywords}" />
	<input type="hidden" name="sfield" value="{$sfield}" />
	<input type="hidden" name="sfield_name" value="p.name,p.id,p.code" />
	<input type="hidden" name="cid" value="{$catid}" />
	<input type="hidden" name="status" value="{$where['status']}" />
</form>
<div class="pageHeader">
	<form  rel="pagerForm" onsubmit="return divSearch(this, 'priceBox');" action="{:U($module_name.'/'.$action_name)}" method="post">
		<input type="hidden" name="m" value="{$module_name}" />
		<input type="hidden" name="a" value="{$action_name}" />
		<input type="hidden" name="cid" value="{$catid}" />
	<div class="searchBar">
		<ul class="searchContent">
			<li style="width:210px;">
				<label style="width:60px;">关键字：</label>
                <input type="text" name="keywords" value="{$keywords}" style="width:120px;"/>
				<!--<input type="text" class="autoinput" name="keywords.keywords" value="{$keywords}" style="width:120px;" postField="keywords" suggestFields="id,keywords" suggestUrl="{:U('Content/suggest',array('tn'=>'ProductCat','fn'=>'id,keywords','field'=>'p.id,pd.name','where'=>myencode(array('category_tag_id'=>$catid),1)))}" lookupGroup="keywords"/>-->
			</li>
			<li style="width:60px;">
			<select name="sfield" class="combox">
				<option value="all" {if $wherefields=='all'}selected="selected"{/if}>全部</option>
				<option value="name" {if $wherefields=='name'}selected="selected"{/if}>产品名称</option>
				<option value="id" {if $wherefields=='id'}selected="selected"{/if}>ID</option>
				<option value="code" {if $wherefields=='code'}selected="selected"{/if}>编号</option>
			</select>
			<input type="hidden" name="sfield_name" value="p.name,p.id,p.code" />
			</li>
			<li>
				<select name="status" class="combox">
					<option value="ALL">全部</option>
					<option value="0" {if $where['status']==='0'}selected="selected"{/if}>未上架</option>
					<option value="1" {if $where['status']==='1'}selected="selected"{/if}>已上架</option>
				</select>
			</li>
			<div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div>
			<div class="buttonActive"><a class="edit" href="{:U('Price/update_ygstatus')}" target="ajaxTodo" title="确定更新云购上下架状态?"><span>一键更新云购上下架状态</span>
			</a>
			</div>
		</ul>
	</div>
	</form>
</div>
<div class="pageContent">

	<div id="order_list">
		<table class="list" width="98%" rel="priceBox" layoutH="100">
		<thead>
			<tr>
				<th width="22"><input type="checkbox" group="ids[]" class="checkboxCtrl"></th>
				<th width="40" orderField="id" {if $orderField=='id'}class="{$orderDirection}"{/if}>ID</th>
				<th width="60" orderField="code" {if $orderField=='code'}class="{$orderDirection}"{/if}>编号</th>			
				<th orderField="name" {if $orderField=='name'}class="{$orderDirection}"{/if}>标题</th>
				<th width="130" orderField="mian_cat" {if $orderField=='mian_cat'}class="{$orderDirection}"{/if}>分类</th>	
				<th>基价/起步/级</th>
				<th>价格</th>
				<th>起批数</th>
				<th>排序</th>
				<th>库存</th>
				<!--<th>最近价格修改（月-日 时:分）</th>	-->			
				<!--<th width="120" orderField="create_date" {if $orderField=='create_date'}class="{$orderDirection}"{/if}>创建时间</th>-->
				<th width="30" orderField="status" {if $orderField=='status'}class="{$orderDirection}"{/if}>状态</th>
				<th width="30">操作</th>
			</tr>
		</thead>
		<tbody>
{if $list}
<volist name="list" id="vo">
	
	<php>
//按行货 水货变动价格
//0410 行货水货0利润，其它利润不变
$jia_hy=1;
if($vo['hoyr']==170||$vo['hoyr']==169||$vo['hoyr']==171){
	$jia_hy=0;
}else{
	$jia_hy=1;
}
</php>
	
			<tr target="sid_dv" rel="{$vo['id']}">
				<td><input name="ids[]" class="chpro" value="{$vo['id']}" type="checkbox"></td>
				<td>{$vo['id']}</td>
				<td>{$vo['code']}</td>
				
				<td><a title="查看{$desc[$vo['id']]['name']}" target="dialog" width="880" height="650" rel="Content_show_{$vo['id']}" href="{:U('Content/show',array('id'=>$vo['id']))}" >{$vo['name']}</a>
				<br/>
				<volist name='vo.attr' id='a'>{if $a['value']}[{$a.value}]&nbsp;&nbsp;{/if}</volist>
				</td>
				
				<td>
					<!--
					<volist name='vo.pricelogs' id='p'>						
						{$p['ctime']|date='m-d H:i',###} &nbsp; 
						<a title="查看用户" target="dialog" width="480" height="500" rel="User_detail_{$p['userid']}" href="{:U('User/detail',array('id'=>$p['userid']))}">{$p.userid} </a>（价格：{$p['jiayi']/100}）<br/>					
					</volist>
					-->
					
					<volist name='vo.cat' id='c'>{if $c['name']}[{$c.name}]&nbsp;&nbsp;{/if}</volist>
					
				
				</td>
				<td>
				    <input type="text" id="jia_0_{$vo.id}" onchange="jia({$vo.id},{$jia_hy})" class="inpddd" size="6" value="{$vo['price_group']['price']/100|default='0'}" tabindex="{$vo.id} ">
            		<input type="text" id="jia_5_{$vo.id}" class="inpddd diyiji" size="3" value="{$vo['price_group']['jiawu']/100|default='0'}">
           			<input type="text" id="jia_6_{$vo.id}" class="inpddd meiji" size="2" value="{$vo['price_group']['jialiu']/100|default='1'}">
				</td>
				<td>
					<div>
                          云购商户：<input type="text" id="jia_1_{$vo.id}" class="inpddd" size="5" value="{$vo['price_group']['jiayi']/100|default='0'}" data-validate="validate(digits);"><br/>
           		  	    全国连锁：<input type="text" id="jia_2_{$vo.id}" class="inpddd" size="5" value="{$vo['price_group']['jiaer']/100|default='0'}" data-validate="validate(digits);"><br/>
                    </div>
                    <div>
             		    省级连锁：<input type="text" id="jia_3_{$vo.id}" class="inpddd" size="5" value="{$vo['price_group']['jiasan']/100|default='0'}" data-validate="validate(digits);"><br/>
            		    市级连锁：<input type="text" id="jia_4_{$vo.id}" class="inpddd" size="5" value="{$vo['price_group']['jiasi']/100|default='0'}" data-validate="validate(digits);">
                        <input type="button" id="{$vo.id}" class="oupddd" value="修改">
                    </div>
               </td>
			 	<input type='hidden' id="catid" name='catid' value='{$catid}' />
				</td>
				<td><input value="{$vo['price_group']['minsale']}" size="5" class="" onblur="updateminsale(this,{$vo['id']});"></td>
				<td><input value="{$vo['sequence']}" size="5" class="ss" onblur="updatesequence(this,{$vo['id']});"></td>
				<td><input value="{$vo['stock']}" size="5" onblur="updatestock(this,{$vo['id']});"></td>
				
				<td>
					{if $vo['status']==0}
					<a title="将商品设置为上架" target="ajaxTodo" rel="jbsxBox" href="{:U('Content/status',array('id'=>$vo['id'],'status'=>'1'))}" class="btnxj">上下架</a>
					{else}
					<a title="将商品设置为下架" target="ajaxTodo" rel="jbsxBox" href="{:U('Content/status',array('id'=>$vo['id'],'status'=>'0'))}" class="btnsj">上下架</a>
					{/if}
				</td>
				<!--<td>{if $vo['create_date']=='0'}-{else}{$vo['create_date']|date="Y-m-d H:i:s",###}{/if}</td>-->
				<td>
					<a title="查看价格修改记录" target="dialog" width="580" height="650" rel="Content_show_{$vo['id']}" href="{:U('Price/priceloglist',array('id'=>$vo['id']))}" class="btnLook">查看</a>
					
				</td>

			</tr>
</volist>
{else}
			<tr><td colspan="7" height="35" align="center">暂无相关产品</td></tr>
{/if}
		</tbody>
	</table>
	</div>
<div class="panelBar">
	<div class="pages">
		<span>显示</span>
		<select class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value},'priceBox')">
			<option value="20" {if $numPerPage==20}selected="selected"{/if}>20</option>
			<option value="50" {if $numPerPage==50}selected="selected"{/if}>50</option>
			<option value="66" {if $numPerPage==66}selected="selected"{/if}>66</option>
			<option value="100" {if $numPerPage==100}selected="selected"{/if}>100</option>
			<option value="200" {if $numPerPage==200}selected="selected"{/if}>200</option>
			<option value="500" {if $numPerPage==500}selected="selected"{/if}>500</option>
		</select>
		<span>条，共{$totalCount}条</span>
	</div>
	
	<div class="pagination" targetType="navTab" rel="priceBox" totalCount="{$totalCount}" numPerPage="{$numPerPage}" pageNumShown="10" currentPage="{$pageNum}"></div>
</div>
</div>
<script>
    $(function(){
        //$('#order_list').ketchup();    
        $.ketchup.createErrorContainer(function(form, el) {
            return $('<ul/>', {
                    'class': 'ketchup-custom'
                    }).insertAfter(el);
        }).addErrorMessages(function(form, el, container, messages) {
            container.html('');

            for(i = 0; i < messages.length; i++) {
            $('<li/>', {
                text: messages[i]
            }).appendTo(container);
            }
        }).showErrorContainer(function(form, el, container) {
            container.slideDown('fast');
        }).hideErrorContainer(function(form, el, container) {
            container.slideUp('fast');
        });

        $('#order_list').ketchup({
            validateEvents: 'blur keyup'
        });
    })
    function updatesequence(obj,id){
		//alert( $(obj).val()+id );
		var o = $(obj);
		$.ajax({
			type:"POST",
			url: "/index.php?s=Price-update_",
			data: 'sque='+o.val()+'&id='+id,
			timeout:"7000",
			dataType:"JSON",
			success: function(msg){},
			error:function(){
				alertMsg.error("time out,try it");
			}
		});
	}
    function updatestock(obj,id){
		//alert( $(obj).val()+id );
		var o = $(obj);
		$.ajax({
			type:"POST",
			url: "/index.php?s=Price-updatestock",
			data: 'stock='+o.val()+'&id='+id,
			timeout:"7000",
			dataType:"JSON",
			success: function(msg){},
			error:function(){
				alertMsg.error("time out,try it");
			}
		});
	}
	
	//更改最小起批数
	function updateminsale(obj,id){
		var o = $(obj);
		$.ajax({
			type:"POST",
			url: "/index.php?s=Price-ajax_minsale",
			data: 'minsale='+o.val()+'&id='+id,
			timeout:"7000",
			dataType:"JSON",
			success: function(msg){},
			error:function(){
				alertMsg.error("time out,try it");
			}
		});
	}
	
	$('input.ss').keyup(function () {
		var $this = $(this);
		$this.val($this.val().replace(/\D/g,"0"));
	});
	if(typeof('showFace')!="function"){
	function ajaxTodo(url){
		$.ajax({
			type: 'POST',
			url: url,
			dataType: "json",
			cache: false,
			success: function(){ $("a", $(".j-num")).parent('.selected').children().click();return 0; },
			error: DWZ.ajaxError
		});
	}}
</script>